﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.CMS.Common.Utility;
using Runda.CMS.Common.Entity;
using Runda.CMS.Bll;
using System.Data;

namespace Runda.CMS.Portal.Workspace
{
    public partial class Notice : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindNoticeList(1);
            }
        }
        private void BindNoticeList(int pageindex)
        {
            DataTable dt = new CommonBll().getDataFromSQL("select top 5 a.NoticeID,a.NoticeContent,a.Noticetime,b.UserName from Cms_Ctrt_MyNotice a inner join cms_sys_user b with(nolock) on a.createdBy = b.userid where a.Deleted = 0 and  " + "NoticeType=" + System.Convert.ToInt32(Enumerator.NoticeMessageType.Public) + " and NoticeID in(select NoticeID from Cms_Ctrt_MyNoticeDepartment where DepartmentID in(select DepartmentID from Cms_Sys_UserDepartment where userid = '" + Session[DeclareHelper.SessionConstant.CurrentUserID].ToString() + "')) order by noticetime desc"); 
            
            RepeaterNotice.DataSource = dt;
            RepeaterNotice.DataBind(); 
           
        }

        protected void RepeaterNotice_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "refersh")
            {
                BindNoticeList(1);
            }
        }
    }
}
